/*
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <hash_map>
#include <set>
#include <vector>
#include <Stack>
#include <iostream>
#include <sstream>
using namespace std;
void swap(int &a,int &b){
	int x=a;
	a=b;
	b=x;
}
int removeDuplicates(vector<int>& nums) {
	if(nums.size()<=1)
		return nums.size();
	int gap=0,len=1,pre=nums[0],preNum=1;
	for(int i=1;i<nums.size();i++){
		if(nums[i]==pre){
			if(preNum<2){
				preNum++;
				len++;
				swap(nums[i],nums[i-gap]);
			}else{
				gap++;
			}
		}else{
			len++;
			pre=nums[i];
			preNum=1;
			swap(nums[i],nums[i-gap]);
		}
	}
	return len;
}
int main(){
	int a[]={1,1,1,2,2,3};
	vector<int>data(a,a+sizeof(a)/sizeof(int));
	cout<<removeDuplicates(data);
	cout<<endl;
	system("pause");
}
*/